#!/usr/bin/env perl
$NginxMainConfPath="./nginx.conf";
$OutPutPath="/tmp/";
$IPPattern='^(((1{0,1}[0-9][0-9])|(2(([0-4][0-9])|(5[0-5]))))\.){3}((1{0,1}[0-9][0-9])|(2(([0-4][0-9])|(5[0-5]))))$';
print "Perl Version is $] \n";
print "NGINX Main configure is $NginxMainConfPath \n";

$Remote_addr="";
$Upstream_addr="";

#print "Input Source IP : ";
#if (<STDIN>=~/$IPPattern/) {
#print $&;
#};

open(DATA,"<$NginxMainConfPath") or die "$NginxMainConfPath 文件无法打开, $!";
@NginxConf=<DATA>;
$NginxConf=join("",@NginxConf);

#读取http模块配置
print "##################http#######################\n";
$NginxConf=~m/http {.*?}/s;
$Http{'content'}=$&;
($Http{'content'}=~/include.*?conf.*?;/);
$Http{'include'}=$&;

print "$Http{'include'}\n";


#读取stream模块配置
print "###################stream######################\n";
$NginxConf=~m/stream {.*?}/s;
$Stream{'content'}=$&;
$Stream{'content'}=~/include.*?lb.*?;/;
$Stream{'include'}=$&;
print "$Stream{'include'}\n";


$Http{'conf'}=[glob($Htt{'include'})];
print $Http{'conf'};
